package triangle.datastructures;

import java.util.*;

public class HashMapSet<T,S> extends HashMap<T, HashSet<S>>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 4801323616311792621L;


	public HashSet<S> put(T key, S doc)
	{
		if (!this.containsKey(key))
			this.put(key, new HashSet<S>());
		if (!this.get(key).contains(doc))
		{
			this.get(key).add(doc);
		}
		return this.get(key);
	}
	
	public boolean contains(T key, S doc)
	{
		return (this.containsKey(key) && this.get(key).contains(doc));
	}
	
	
	public String toString()
	{
		String stringify = "";
		for (T key : super.keySet())
		{
			stringify += "" + key + ":" + this.get(key).toString() + "\n";
		}
		return stringify;
	}

}
